import { _decorator, Component, EditBox, Label, Node, safeMeasureText, UITransform } from 'cc';
import { EDITOR } from 'cc/env';
const { ccclass, property } = _decorator;

@ccclass('testInput')
export class testInput extends Component {
    @property(Label)
    testLabel = null;
    @property
    set test(v){
        this._test = v;
        console.log("test"+(safeMeasureText(this.testLabel.assemblerData.context, v)+4))
        this.testLabel.string = v;
        this.UpdateLabel()
    }
    get test(){
        return this._test
        
    }


    _test = "123"

    LabelNode=null;

 

    public UpdateLabel(){


            var textWidth = safeMeasureText(this.testLabel.assemblerData.context, this.testLabel.string)+4;
            console.log("width ="+textWidth)
            this.node.getComponent(UITransform).setContentSize(textWidth,100)
            // const labelWidget=this.LabelNode.getComponent("LabelWidget")
            // if(labelWidget && this._edit){
            //     labelWidget.SetLabel(this._edit.string);
            // }
        }
    }
